﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FSS.Core.Controls;
using FSS.Core.Util;
using IBatisNet.Common.Logging;
using Ext.Net;
using FSS.BLL.Entities;
using FSS.BLL.Services;

namespace SalesManagement.Modules.List
{
    public partial class InOutMethod : BasePage, IBaseListPage
    {
               private static readonly ILog log = LogManager.GetLogger(typeof(InOutMethod));
       public InOutMethod()
            : base(SCREENS.INOUTMETHOD)
        {

        }

        protected void Page_Load(object sender, EventArgs e)
        {
            base.CheckPermissionControl();
            this.WindowEditor.SaveClick += new EventHandler(WindowEditor_SaveClick);
        }

        void WindowEditor_SaveClick(object sender, EventArgs e)
        {
            BindingGrid();
        }
        [DirectMethod]
        public void DocumentReady()
        {
            BindingGrid();
        }
        private void BindingGrid()
        {
            InOutMethodService inoutS = InOutMethodService.GetInstance();
            IList<InOutMethodEntity> lstInOut = inoutS.LoadAll();
            if (null != lstInOut)
            {
                this.storeMain.DataSource = lstInOut;
                this.storeMain.DataBind();
            }
        }
        protected void grdMain_OnCommand(object sender, DirectEventArgs e)
        {
            string id = e.ExtraParams["id"];
            string command = e.ExtraParams["command"];
            if (IsEdit && Constants.Edit.Equals(command))
            {
                this.WindowEditor.Show(id);
            }
            else if (IsDelete && Constants.Delete.Equals(command))
            {
                InOutMethodEntity inoutMethodE = new InOutMethodEntity();
                InOutMethodService inoutMethodS = InOutMethodService.GetInstance();
                inoutMethodE.MethodId = int.Parse(id);
                inoutMethodS.Delete(inoutMethodE);
                BindingGrid();
            }

        }
        public void btnAdd_Click(object sender, DirectEventArgs e)
        {
            this.WindowEditor.ShowAndReset();
        }
        public void btnEdit_Click(object sender, DirectEventArgs e) { }
        public void btnDelete_Click(object sender, DirectEventArgs e) { }
        public void btnPrint_Click(object sender, DirectEventArgs e) { }
        public void btnImport_Click(object sender, DirectEventArgs e) { }
        public void btnExport_Click(object sender, DirectEventArgs e) { }
        public void btnFind_Click(object sender, DirectEventArgs e) { }
    }
}
